package com.wisdom.weld.pojo;

import com.wisdom.weld.enumeration.JavaType;
import com.wisdom.weld.enumeration.JdbcType;

import java.util.HashMap;
import java.util.Map;

public class JdbcJavaMapping {
    private static final Map<JdbcType, JavaType> MAPPING = new HashMap<JdbcType, JavaType>();

    static {
        MAPPING.put(JdbcType.VARCHAR, JavaType.STRING);
        MAPPING.put(JdbcType.CHAR, JavaType.STRING);
        MAPPING.put(JdbcType.TEXT, JavaType.STRING);
        MAPPING.put(JdbcType.TINYINT, JavaType.INTEGER);
        MAPPING.put(JdbcType.SMALLINT, JavaType.INTEGER);
        MAPPING.put(JdbcType.SMALLINT, JavaType.INTEGER);
        MAPPING.put(JdbcType.INT, JavaType.INTEGER);
        MAPPING.put(JdbcType.BIGINT, JavaType.LONG);
        MAPPING.put(JdbcType.FLOAT, JavaType.FLOAT);
        MAPPING.put(JdbcType.DOUBLE, JavaType.DOUBLE);
        MAPPING.put(JdbcType.DATE, JavaType.DATE);
        MAPPING.put(JdbcType.TIME, JavaType.DATE);
        MAPPING.put(JdbcType.TIMESTAMP, JavaType.DATE);
        MAPPING.put(JdbcType.DATETIME, JavaType.DATE);
    }

    public static JavaType getJavaType(JdbcType jdbcType) {
        return MAPPING.get(jdbcType);
    }

}
